const search = {
  props: {
      params: {
        type: Object
      },
      initData: {
        type: Object
      } 
  },
  data(){
      return{
          reset_search: {},
      }
  },
  watch: {
    form: {
      handler(newVal) {
        this.$emit('update:params', newVal)
      },
      immediate: true,
      deep: true
    }
  },
  computed:{
    init_data(){
      return JSON.parse(JSON.stringify(this.initData))
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.reset_search = Object.assign({}, this.form)
      for (const key in this.init_data) {
        this.init_data[key].unshift({ id: null, name: '全部' })
      }
      this.initCallback();
    },
    initCallback(){

    },
    resetSearch() {
      this.$util.resetForm(this.form, this.reset_search);
      this.resetSearchCallback();
      this.$emit('search', this.form)
    },
    resetSearchCallback(){

    },
    handleSearch() {
      this.$emit('search', this.form)
    }
  }
}

export default search;